package com.lagou.service.impl;

import com.lagou.service.MailService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 1:46 下午 2022/1/31
 */
@Service
public class MailServiceImpl implements MailService {
    @Value("${spring.mail.username}")
    private String from;

    @Resource
    private JavaMailSender sender;

    @Override
    public boolean sendMail(String mail, String msg) {
        SimpleMailMessage message=new SimpleMailMessage();
        message.setFrom(from);
        message.setTo(mail);
        message.setText(msg);
        sender.send(message);
        System.out.println("邮件发送成功");
        return true;
    }

    @Override
    public String send( String msg) {
        System.out.println("msg:"+msg);
        return  msg;
    }


}
